package com.cn.client;

import com.cn.client.impl.DefaultMQPushConsumerImpl;
import com.cn.common.ServerThread;

/**
 * 根据topic信息，构造该topic对应的processQueue队列，然后分配该节点拥有哪些队列
 */
public class RemplanceService extends ServerThread {

    private DefaultMQPushConsumerImpl defaultMQPushConsumer;

    public RemplanceService(DefaultMQPushConsumerImpl defaultMQPushConsumer) {
        this.defaultMQPushConsumer = defaultMQPushConsumer;
    }

    @Override
    public String getServiceName() {
        return RemplanceService.class.getSimpleName();
    }

    @Override
    public void run() {
        System.out.println("do remplance start");
        while (!isStopped()) {
            waitForRunning(20000);//每30秒执行一次，然后检测messageQueue并重新锁定队列，然后构造pullrequest
            this.defaultMQPushConsumer.doRemplance();
        }
        System.out.println("do remplance end");
    }

}
